efform_onload = function ()
{
	$('#flag').val()==1
//	if($('#flag').val()==1)
//	{
//	   document.getElementById('ef_region_inqu').style.display = "none";
//	}
	$('#ef_grid_result-0-fdDepartmentId').val($('#fdDepartmentId').val());
};  

button_query_onclick = function () 
{   	
	efgrid.submitInqu( "ef_grid_result", "ZM","ZMCG82","query");
}
button_update_onclick = function (){ 
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		var fdWorkbeforeTime = grid.getCellValueByColumnName(rows[i],"fdWorkbeforeTime"); //班前确认时间
		var fdWorkmoddleTime = grid.getCellValueByColumnName(rows[i],"fdWorkmoddleTime"); //班中确认时间
		var fdWorklastTime = grid.getCellValueByColumnName(rows[i],"fdWorklastTime");  //班末确认时间
		if(fdWorkmoddleTime <= fdWorkbeforeTime)
		{
			EFAlert("班中时间早于班前时间"); return;
		}
		if(fdWorklastTime <= fdWorkmoddleTime)
			{
			EFAlert("班末时间早于班中时间"); return;
			}
	}
	if (isSelected("ef_grid_result") == 0)return; 
	efgrid.submitForm( "ef_grid_result", "ZM","ZMCG82","update",true);
}
button_insert_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		var fdWorkbeforeTime = grid.getCellValueByColumnName(rows[i],"fdWorkbeforeTime"); //班前确认时间
		var fdWorkmoddleTime = grid.getCellValueByColumnName(rows[i],"fdWorkmoddleTime"); //班中确认时间
		var fdWorklastTime = grid.getCellValueByColumnName(rows[i],"fdWorklastTime");  //班末确认时间
		if(fdWorkmoddleTime <= fdWorkbeforeTime)
		{
			EFAlert("班中时间早于班前时间"); return;
		}
		if(fdWorklastTime <= fdWorkmoddleTime)
			{
			EFAlert("班末时间早于班中时间"); return;
			}
	}
	if (isSelected("ef_grid_result") == 0)return; 
	efgrid.submitForm( "ef_grid_result", "ZM","ZMCG82","insert",true);
} 
button_delete_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行删除！"); return;
		}
	}
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM","ZMCG82","delete",true);
	}); 
}


button_report_onclick = function (){
	if (isSelected("ef_grid_result") == 0)return; 
	EFConfirm('确认要上报吗?', '确认框', function(r) {
		efgrid.submitForm( "ef_grid_result", "ZM","ZMCG82","report",true);
	});
}

efgrid_afterAddNewRow = function(grid_id){ 
	var grid = efgrid.getGridObject(grid_id);
	var rows = grid.getCheckedRows(); 
	if(grid_id=="ef_grid_result")
	{
		var fdDepartmentId=$('#fdDepartmentId').val(); 
	   
		for(var i = 0 ; i < rows.length;i++){
			grid.setCellValue(rows[i],2,fdDepartmentId,TYPE_DATA); 
		}
	}
}
